package com.jiang.daily.Q2843;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/04/11 17:01
 */
public class Solution {
    public int countSymmetricIntegers(int low, int high) {
        int res = 0;
        for (int i = low; i <= high; i++) {
            char[] arr = Integer.toString(i).toCharArray();
            int len = arr.length;
            if (len % 2 != 0) continue;
            int mid = len / 2;
            int l = 0;
            int r = 0;
            for (int j = 0; j < mid; j++) {
                l += arr[j] - '0';
            }

            for (int j = mid; j < len; j++) {
                r += arr[j] - '0';
            }

            if (l == r) res++;

        }
        return res;
    }
}
